08. Better Practices
Constants
Constants vs Strings
SOLUTION:
- We can ensure an error will be thrown for misspelled action types
Action Creators
Start Quiz:
/* Create An Action Creator
*
* You need to create an action creator called 'mealCreator' that should:
* - Accept an id
* - Return a Redux action with a 'type' property that has a value of 'CREATE_MEAL'
* - Include the id passed to the action creator
*/
Summary
In this section, we converted our actions to use JavaScript constants instead of strings. We also refactored our .dispatch()
calls from passing in unique objects directly to them, to calling special functions that create the action objects - these special functions that create action objects are called Action Creators.